home *** CD-ROM | disk | FTP | other *** search
/ Greenhouse Effect Detection Expriment / NASA Greenhouse Effect Detection Expriment 1992 - Disc 2.iso / software / dos / cdf22pc / src / include / vio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-12  |  4.1 KB  |  143 lines

  1. /******************************************************************************
  2. *
  3. *  NSSDC/CDF                        Header file for VIO
  4. *
  5. *  Version 3.0, 12-Feb-92, ST Systems (STX)
  6. *
  7. *  Modification history:
  8. *
  9. *   V1.0  24-Jan-91, J Love    Original version (for CDF V2.0).
  10. *   V1.1  14-Mar-91, J Love    Added "extend" block.
  11. *   V2.0   6-Jun-91, J Love    Changed for CACHEing (for CDF V2.1).
  12. *   V2.1  31-Jul-91, J Love    Added miscellaneous macro definitions.  Added
  13. *                fields to VFILE structure.  Renamed functions
  14. *                to avoid collisions on SGi/IRIX.
  15. *   V3.0  12-Feb-92, J Love    IBM PC port.
  16. *
  17. ******************************************************************************/
  18.  
  19. #if !defined(___vio_h___)
  20. #define ___vio_h___
  21.  
  22. /*****************************************************************************/
  23.  
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <string.h>
  27.  
  28. /******************************************************************************
  29. * Miscellaneous macros.
  30. ******************************************************************************/
  31.  
  32. #if defined(unix)
  33. #if !defined(memmove)
  34. #define memmove(dst,src,n) bcopy(src,dst,n)
  35. #endif
  36. #endif
  37.  
  38. #if !defined(TRUE)
  39. #define TRUE (-1)
  40. #endif
  41.  
  42. #if !defined(FALSE)
  43. #define FALSE 0
  44. #endif
  45.  
  46. #if !defined(SEEK_SET)
  47. #define SEEK_SET 0
  48. #endif
  49.  
  50. #if !defined(SEEK_CUR)
  51. #define SEEK_CUR 1
  52. #endif
  53.  
  54. #if !defined(SEEK_END)
  55. #define SEEK_END 2
  56. #endif
  57.  
  58. #if !defined(Minimum)
  59. #define Minimum(a,b) ((a) < (b) ? (a) : (b))
  60. #endif
  61.  
  62. #if !defined(Maximum)
  63. #define Maximum(a,b) ((a) > (b) ? (a) : (b))
  64. #endif
  65.  
  66. /******************************************************************************
  67. * Constants.
  68. ******************************************************************************/
  69.  
  70. #define VIO_MAGIC_NUMBER    0x12345678    /* Used to verify that a VFILE
  71.                            structure has been passed
  72.                            to a function. */
  73.  
  74. #define DEFAULT_nCACHE_BUFFERs    5        /* Default number of buffers
  75.                            in the cache (if 0 specified
  76.                            at open). */
  77. #define nCACHE_BUFFER_BYTEs    512        /* Size (bytes) of each cache
  78.                            buffer. */
  79.  
  80. #if defined(vms)
  81. #define VMS_DEFAULT_nALLOCATION_BLOCKS    3    /* Allocate only 3 blocks at
  82.                            a time (override VMS default
  83.                            of 128 for fixed record
  84.                            length file). */
  85. #endif
  86.  
  87. #define vioMAX_TRYs    10        /* Maximum number of trys on a
  88.                        read or write operation. */
  89.  
  90. /******************************************************************************
  91. * VFILE structure.
  92. ******************************************************************************/
  93.  
  94. struct VFILEstruct {
  95. long magic_number;    /* Magic number for VFILE structure. */
  96. FILE *fp;        /* file pointer */
  97. long offset;        /* read/write position (byte offset) in file */
  98. long eof;        /* end-of-file byte (includes what is in the cache but
  99.                not necessarily what is physically in the file) */
  100. long error;        /* TRUE if an error has occurred - no further access
  101.                to the file is allowed */
  102. long nCACHEbuffers;    /* number of CACHE buffers */
  103. char **CACHEbuffers;    /* cache buffers */
  104. long *CACHEblockN;    /* file block number in corresponding cache buffer */
  105. long *CACHEmodified;    /* TRUE if cache buffer has been modified */
  106. long *CACHEaccessedAt;    /* when buffer was last accessed (pseudo time) */
  107. long lastBufferNaccessed; /* contains last buffer accessed - used to speed up
  108.                 search for which buffer maps to a file block */
  109. long PHYeof;        /* physical EOF (byte offset) of the file */
  110. long PHYlastBlockN;    /* physical last block of the file */
  111. long pseudoClock;    /* used to keep track of buffer access times */
  112. };
  113.  
  114. typedef  struct VFILEstruct    VFILE;
  115.  
  116. /******************************************************************************
  117. * Function prototypes.
  118. ******************************************************************************/
  119.  
  120. #if defined(vms) | defined(__MSDOS__)
  121. VFILE *Vopen (char *, char *, long);
  122. int Vseek (VFILE *, long, int);
  123. long Vtell (VFILE *);
  124. int Veof (VFILE *);
  125. long Vread (void *, long, long, VFILE *);
  126. long Vwrite (void *, long, long, VFILE *);
  127. int Vclose (VFILE *);
  128. #endif
  129.  
  130. #if defined(unix)
  131. VFILE *Vopen ();
  132. int Vseek ();
  133. long Vtell ();
  134. int Veof ();
  135. long Vread ();
  136. long Vwrite ();
  137. int Vclose ();
  138. #endif
  139.  
  140. /*****************************************************************************/
  141.  
  142. #endif   /*___vio_h___*/
  143.